package java8Com.chap3;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

/**
 * 行为参数，环绕执行
 */
public class file {

    public static String processFileLimited() throws IOException {
        try (BufferedReader br =
                     new BufferedReader(new FileReader("lambdasinaction/chap3/data.txt"))) {
            return br.readLine();
        }
    }


    public static String fileProcess(BufferedReaderProcessor p) throws IOException {
        try (BufferedReader br =
                     new BufferedReader(new FileReader("lambdasinaction/chap3/data.txt"))) {
            return p.press(br);
        }
    }

    public interface BufferedReaderProcessor{
        String press(BufferedReader bufferedReader) throws IOException;
    }

    public static void main(String[] args) throws IOException{
        String s=fileProcess((BufferedReader br) -> br.readLine()+br.readLine());

        BufferedReaderProcessor bufferedReaderProcessor=(BufferedReader br) -> br.readLine()+br.readLine();
    }
}
